﻿using Domain;
using Microsoft.AspNet.SignalR;
using Task = System.Threading.Tasks.Task;

namespace SilverlightRest.Web.SignalR
{
    public class MyHub : Hub
    {
        public Task JoinGroup(string groupName)
        {
            return Groups.Add(Context.ConnectionId, groupName);
        }

        public Task LeaveGroup(string groupName)
        {
            return Groups.Remove(Context.ConnectionId, groupName);
        }

        public void HelloGroup(string groupName, string input)
        {
            Clients.Group(groupName).groupmessage(input);
        }

        public void TriggerSendPerson()
        {
            var result = new Person {Name = "morten"};
            Clients.All.SendPerson(result);
        }

        public void Hello(string input)
        {
            Clients.All.hello(input);
        }
    }
}